package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.CourseMapper;
import com.course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;
    @Override
    public ResultBody addcourse(Map<String, Object> map) {
        if(courseMapper.addcourse(map)>0&&courseMapper.addteach(map)>0){
            return new ResultBody(200, "添加成功", true);
        }
        return new ResultBody(400, "添加失败", false);
    }

    @Override
    public ResultBody updatecourse(Map<String, Object> map) {
        if(courseMapper.updatecourse(map)>0){
            return new ResultBody(200, "修改成功", true);
        }
        return new ResultBody(400, "修改失败", false);
    }

    @Override
    public ResultBody deletecourse(long courseid) {
        if(courseMapper.deletecourse(courseid)>0){
            return new ResultBody(200, "删除成功", true);
        }
        return new ResultBody(400,"删除失败", false);
    }
}
